package com.zyddd.controller;

import com.zyddd.common.R;
import com.zyddd.utils.EmailUtil;
import com.zyddd.utils.RandomCaptcha;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("email")
public class EmailController {
    @Autowired
    private EmailUtil emailUtil;

    @GetMapping("send")
    public R<String> sendEmail(String to) {
        String captcha = RandomCaptcha.get(6);
        emailUtil.sendMessage(to, "智能出版系统注册", captcha);
        return R.success("操作成功", captcha);
    }
}
